﻿using System;

namespace NeuralLib.ActivationFunction
{
    [Serializable]
    public class BipolarSigmoidFunction : IActivationFunction
    {
        private double _alpha = 2;

        public double Alpha
        {
            get { return _alpha; }
            set { _alpha = value; }
        }

        public BipolarSigmoidFunction() { }

        public BipolarSigmoidFunction(double alpha)
        {
            _alpha = alpha;
        }


        public double Function(double x)
        {
            return ((2 / (1 + Math.Exp(-_alpha * x))) - 1);
        }

        public double Derivative(double x)
        {
            var y = Function(x);

            return (_alpha * (1 - y * y) / 2);
        }

        public double Derivative2(double y)
        {
            return (_alpha * (1 - y * y) / 2);
        }
    }

}
